import { ModalForm, ProCard, ProFormText } from '@ant-design/pro-components';
import { Button, Space, message } from 'antd';
import React, { useState } from 'react';
import ProCardModel from './ProCardModel';
import dayjs from 'dayjs';

const waitTime = (time: number = 100) => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve(true);
        }, time);
    });
};

interface showModalInfo {
    data: Record<string, string> | null;
    open: boolean;
    onOpenChange?: Function;
    onFinish?: Function;
}

function ShowModelInfo({ data, open = false, onOpenChange, onFinish }: showModalInfo) {
    const formRef = React.useRef(null);
    const [responsive, setResponsive] = useState(false);

    return (
        <Space>
            <ModalForm
                open={open}
                submitter={false}
                onOpenChange={(open) => onOpenChange?.(open)}
                formRef={formRef}
                width={1200}
                modalProps={{
                    destroyOnClose: true,
                    maskClosable: false,
                }}
                onFinish={async (values) => {
                    // 指定对象类型
                    const payload: Record<string, string | number> = {
                        ...values,
                    };
                    if (data) {
                        payload.id = data.id;
                        return true;
                    }
                    return true;
                }}
                initialValues={data as any}
            >
               <ProCardModel
                    data={data}
                    />
            </ModalForm>
        </Space>
    );
};

export default ShowModelInfo;